﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XingFuStudio.Pioneer.Applications.City.Entity;

namespace XingFuStudio.Pioneer.Applications.City.Element {
    /// <summary>
    /// 基础设施信息实体
    /// </summary>
    public class InfrastructureInfo : CityElement{
        /// <summary>
        /// 是否可以收获
        /// </summary>
        public bool CanHarvest {
            get {
                return this.ElapseTime > 24 * 60 * 60;
            }
        }
        
        /// <summary>
        /// 上次收获时间
        /// </summary>
        public DateTime LastHarvestTime {
            get;
            private set;
        }

        /// <summary>
        /// 推移时间
        /// </summary>
        public int ElapseTime {
            get;
            private set;
        }

        /// <summary>
        /// 初始化元素自身数据
        /// </summary>
        /// <param name="elementObject"></param>
        public override void InitElement(Dictionary<string, object> elementObject) {
            //调用基类方法
            base.InitElement(elementObject);

            //赋值自身属性
            this.LastHarvestTime = Convert.ToDateTime(elementObject["collecttime"]);
            this.ElapseTime = Convert.ToInt32(elementObject["elapsetime"]);
        }
    }
}
